﻿<%@ WebHandler Language="C#" Class="BrandSortHandler" %>

using System;
using System.Web;
using SeDuce.BLL;
using SeDuce.Model;

public class BrandSortHandler : IHttpHandler {

    Lazy_Yu<BrandBLL> lazyBrandBLL = new Lazy_Yu<BrandBLL>(() => new BrandBLL());
    public BrandBLL LazyBrandBLL
    {
        get { return this.lazyBrandBLL.Value; }
        
    }
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        BrandData brandData = context.Request.Form["branddata"].ToString().FromJsonTo<BrandData>();

        JSONStatus status = new JSONStatus() { Status = "0" };
        if (brandData.BrandList.Count > 0)
        {
            if (!this.LazyBrandBLL.UpdateBrands(brandData.BrandList))
            {
                status.Status = "1";
            }
        }

        context.Response.Write(status.ToJSON());
        context.Response.End();
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}